package com.xyy.saas.payment.cores.enums;

import lombok.Getter;

/**
 * @author wangzeqi
 */
@Getter
public enum AbchinaLoanStatusEnum {

    SUBMITTED("01", "申请已提交（待审核）"),
    APPROVED("02", "审核已通过（用户待签约）"),
    SIGNED("03", "用户已签约（待用款）"),
    REJECTED("04", "申请未通过"),
    NOT_APPLIED("05", "未申请"),
    ;
    private final String code;
    private final String description;

    AbchinaLoanStatusEnum(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public static AbchinaLoanStatusEnum fromCode(String code) {
        if (code == null || code.isEmpty()) {
            return null;
        }
        for (AbchinaLoanStatusEnum status : values()) {
            if (status.code.equals(code)) {
                return status;
            }
        }
        return null;
    }

    public static PinganLoanApplyStatusEnum getPinganLoanApplyStatusEnum(String code) {
        AbchinaLoanStatusEnum abchinaLoanStatusEnum = fromCode(code);
        if (abchinaLoanStatusEnum == null) {
            return null;
        }
        switch (abchinaLoanStatusEnum) {
            case SUBMITTED:
                return PinganLoanApplyStatusEnum.APPROVING;
            case APPROVED:
                return PinganLoanApplyStatusEnum.APPROVE_PASS;
            case SIGNED:
                return PinganLoanApplyStatusEnum.SIGNED_CONT_SUCCESS;
            case REJECTED:
                return PinganLoanApplyStatusEnum.APPROVE_DENY;
            case NOT_APPLIED:
                return PinganLoanApplyStatusEnum.UN_PRE_APPLY;
            default:
                return null;
        }
    }

}
